package com.haizhi.oa;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MqttTest {
	public static void main(String[] args) {
		if(args.length!=6){
			System.err.println("TIPS : java -jar mqttclient.jar me_id url topic clientId username password");
			return ;
		}
		
		String me_id = args[0];
		String url = args[1];
		String topic = args[2];
		String clientId = args[3];
		String username = args[4];
		String password = args[5];
		
		MqttClientUtil client = new MqttClientUtil(me_id,url, topic, 1, clientId,username, password);
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = buf.readLine();
			while (!str.equals("exit")) {
				String[] ss = str.split(":");
				if(ss.length==2){
					client.sendMessage(ss[0],ss[1]);
				}
				str = buf.readLine();
			}
			buf.close();
			client.disconnect();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
